﻿function ChkSelectAll(chknameStr,chkallnameStr){
	var arrInput = document.getElementsByTagName('input');
	var arrCheckbox = [];
	var chkname = [];
	var chkallname;
	for(var j=0;j<arrInput.length;j++){
	    if(arrInput[j].type.toLowerCase()=='checkbox') arrCheckbox[arrCheckbox.length] = arrInput[j];
	}
	for(j=0;j<arrCheckbox.length;j++){
	    if(arrCheckbox[j].name==chknameStr) chkname[chkname.length] = arrCheckbox[j];
		else if(arrCheckbox[j].name==chkallnameStr) chkallname = arrCheckbox[j];
	}
	
	var length = chkname.length;   
    chkallname.checked = chkallname.checked|0;

    for (var i = 0; i < length; i++) if(!chkname[i].disabled) chkname[i].checked=chkallname.checked;            
}
function unChkSelectAll(chkallnameStr){
	var arrInput = document.getElementsByTagName('input');
	var arrCheckbox = [];
	var chkallname;
	for(var j=0;j<arrInput.length;j++){
	    if(arrInput[j].type.toLowerCase()=='checkbox') arrCheckbox[arrCheckbox.length] = arrInput[j];
	}
	for(j=0;j<arrCheckbox.length;j++){
		if(arrCheckbox[j].name==chkallnameStr) chkallname = arrCheckbox[j];
	}
	
	if(chkallname.checked) chkallname.checked = chkallname.checked&0;
}